<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Webcam</title>
	<link rel="stylesheet" href="${request.contextPath}/styles/webcam.css" type="text/css"/>
	<script type="text/javascript" src="scripts/jquery/jquery.js"></script>
	<script type="text/javascript" src="scripts/jquery/webcam/jquery.webcam.js"></script>
	
	<script type="text/javascript">
		function handleClick() {
			alert('Webcam: '+webcam);
			webcam.capture();
		}

		if (jQuery.browser.msie && jQuery.browser.version == 9) {
		    window.XMLSerializer = function() {

		    };
		    window.XMLSerializer.prototype.serializeToString = function(oNode) {

		      return oNode.xml;

		    };
		  }
	</script>
</head>
<body>

<div id="webcam">
	<span>&nbsp;</span>
</div>

<div style="width:360px;text-align:center; ">
	<a onclick="handleClick();" href="#">Click</a>
</div>

<script type="text/javascript">

	var superdata = "";
	
	jQuery("#webcam").webcam({
	
		width: 320,
		height: 240,
		mode: "callback",
		swffile: "webcam/jscam.swf",
	
		onTick: function(remain) {	
		},
	
		onSave: function(data) {
			superdata+=data + "|";
		},
	
		onCapture: function () {
	
			superdata="";
			webcam.save();
	
			$.post(  "bss/images/click", { data1: superdata},
					  function(dta) {				  					   
			            clicked(dta);				   
					   }, "html");
		},
	
		debug: function (type, string) {		
		},
	
		onLoad: function () {
		}
	});

	function clicked(im) {
		try {
			window.dialogArguments.setImage(im);
		}catch(e) {
			try {
				window.opener.doSubmit(im);
			}catch(e) {
				alert(e);
			}
		}
		window.close();
	}
</script>

</body>
</html>